import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    mallcat: [],
    mao: '嘻嘻'
  },
  mutations: {
    // addcart(state, payload) {
    //   state.mallcat.push(payload)
    // }
    addcart(state, payload) {
      let olditem = state.mallcat.find(item =>
        item.iid === payload.iid
      )
      if (olditem) {
        olditem.count += 1
      } else {
        payload.count = 1
        state.mallcat.push(payload)
      }
    }
  },
  actions: {

  }
})
